package maquinaV;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class MemoriaInstrucciones {

	private ArrayList<Instruccion> Inst;
	
	public MemoriaInstrucciones(){
		Inst=new ArrayList<Instruccion>();
	}
	
	public void cargaCod(String ruta) {
       		
		  
			try {
				FileReader fr;
				fr = new FileReader(ruta);
				BufferedReader bf = new BufferedReader(fr);
	    		String s;
	    		String[] a= new String[3];
	    		while ((s = bf.readLine())!=null) {
	    				a=s.split("\\s+");
	    		
				if (a.length==1)
					Inst.add(new Instruccion(a[0],"",""));
					else if (a.length==2){
						Inst.add(new Instruccion(a[0],a[1],""));
					}
					else Inst.add(new Instruccion(a[0],a[1],a[2]));
				}
			
           } catch (FileNotFoundException archivoNoEncontrado){
        	   archivoNoEncontrado.printStackTrace();
        	} catch (IOException e) {
			  e.printStackTrace();
		}
	}
   
	public Instruccion dameInstruccion(int i){
		return Inst.get(i);
	}
	
	
}	
